/*
 * @Author: 一路向阳 tt_sunzhenfeng@163.com
 * @Date: 2024-02-21 19:18:11
 * @LastEditors: 一路向阳 tt_sunzhenfeng@163.com
 * @LastEditTime: 2024-02-21 19:31:29
 * @FilePath: \utils_ts\18.泛型（类型别名，接口）.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export {};

// 泛型-类型别名
type StrOrNum = string | number;
// type ObjType = {name: string, getName: () => string}
type ObjType<N, G> = {name: N, getName: () => G}

const obj: ObjType<StrOrNum, StrOrNum> = {
  name: 23,
  getName() {
    return 1;
  }
}

// 泛型 - 接口

// interface PersonItf {
//   name: string;
//   getName: () => string;
// }

interface PersonItf<N,G = string> {
  name: N;
  getName: () => G;
}

const obj2: PersonItf<StrOrNum, number> = {
  name: 23,
  getName() {
    return 1;
  }
}